<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Api\V1;

use Think\Exception;
use Think\Model;

class UserRegSubmit
{
    public $login = true; //是否需要登录才能访问该接口
    public $title = "002个人申请租房";
    public $group = '租房';
    public $desc = "";

    public $input = [
        'reg_real_name' => 'required;label=申请人真实姓名;',
        'reg_sex' => 'required;int;label=性别;comment=性别： 0女 1男 2未知;',
        'reg_idcard' => 'required;;label=申请人身份证号码',
        'reg_age' => 'required;int;label=申请人年龄',
        'reg_mobile' => 'required;int;label=申请人联系电话',
        'home_num' => 'required;int;label=申请人身份证号码',
        'company' => 'required;label=工作单位',
        'contact_real_name' => 'required;label=通讯联系人姓名',
        'contact_idcard' => 'required;label=通讯人身份证',
        'contact_address' => 'required;label=通讯人地址',
    ];

    public $output = [

    ];

    public function run($param, $uid, $login_info)
    {
        $param['uid'] = $uid;
        $result = M('user_reg')->add($param);
        if($result === false){
            throw new Exception('申请失败');
        }

        return $result;
    }
}
